package com.matt.controller.pad;

import com.matt.commons.model.StatusResponse;
import com.matt.commons.page.PagerQuery;
import com.matt.domain.courseV2.ChildrenMonthTemplate;
import com.matt.service.courseV2.ChildrenMonthRecordService;
import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static com.matt.foundation.constant.RequestConstant.TICKET;


@RestController
@RequestMapping("/pad/children_month_template")
@Slf4j
@Api(tags = "学生 - 月报模板")
public class PadChildrenMonthTemplateController {

    @Autowired
    private ChildrenMonthRecordService childrenMonthRecordService;


    @ApiOperation(value = "获取")
    @PostMapping("/get")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "templateId", value = "模板ID", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 000000, message = "successful", response = ChildrenMonthTemplate.class),
    })
    public StatusResponse getChildrenMonthTemplate(@RequestHeader(TICKET) String ticket,String templateId) {
        ChildrenMonthTemplate po = childrenMonthRecordService.getChildrenMonthTemplate(templateId);
        return StatusResponse.success(po);
    }

    @ApiOperation(value = "列表")
    @PostMapping("/list")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "pageNum", value = "分页", required = true, dataType = "string"),
            @ApiImplicitParam(paramType = "query", name = "pageSize", value = "分页", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 000000, message = "successful", response = ChildrenMonthTemplate.class),
    })
    public StatusResponse getChildrenMonthTemplateList(@RequestHeader(TICKET) String ticket,PagerQuery pagerQuery) {
        Page<ChildrenMonthTemplate> po = childrenMonthRecordService.getChildrenMonthTemplateList(pagerQuery);
        return StatusResponse.success(po);
    }

    @ApiOperation(value = "添加")
    @PostMapping("/add")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "templateId", value = "模板ID", required = true, dataType = "string"),
    })
    @ApiResponses({
            @ApiResponse(code = 000000, message = "successful", response = ChildrenMonthTemplate.class),
    })
    public StatusResponse getChildrenMonthTemplate(@RequestHeader(TICKET) String ticket, ChildrenMonthTemplate childrenMonthTemplate) {
        ChildrenMonthTemplate po = childrenMonthRecordService.add(childrenMonthTemplate);
        return StatusResponse.success(po);
    }

}
